/*
 * Created on 2008-8-26
 *
 * TODO
 */
package jacky.lanlan.song.junitx.v4.atunit.mockito;

import static org.mockito.Mockito.mock;

import jacky.lanlan.song.junitx.v4.atunit.Mock;
import jacky.lanlan.song.junitx.v4.atunit.Stub;
import jacky.lanlan.song.junitx.v4.atunit.core.MockGenerator;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;


public class MockitoFramework implements MockGenerator {

	public Map<Field, Object> generateMocks(Field[] fields) throws Exception {
		Map<Field,Object> mocksAndStubs = new HashMap<Field,Object>();
		
		for(Field field : fields) {//遍历 Field
			// 过滤需要Mock的Field
			if(field.isAnnotationPresent(Mock.class) ||	field.isAnnotationPresent(Stub.class)) {
				mocksAndStubs.put(field, mock(field.getType()));
			}
		}
		
		return mocksAndStubs;
	}

}
